package com.asia5b.a5mall.middleware.model.member

import com.asia5b.a5bmall.resource.ResString
import com.asia5b.a5mall.middleware.R
import com.asia5b.a5mall.middleware.utils.TimeHandle
import com.chad.library.adapter.base.entity.MultiItemEntity
import java.io.Serializable

/**
 * Created by zhangyuncai on 2020/1/22.
 * 活动
 */
class PromotionModel : Serializable, MultiItemEntity {

    var goods_id = 0
    var title = ""

    /**单品立减*/
    var minus_vo: PromotionMinusvo? = null
    /**满减组合*/
    var full_discount_vo: PromotionFulldiscountvoModel? = null
    /**第二件半价*/
    var half_price_vo: PromotionHalfpricevo? = null
    /**积分商城*/
    var exchange: PromotionExchange? = null
    /**团购*/
    var groupbuy_goods_vo: PromotionGroupbuygoodsvo? = null
    /**秒杀*/
    var seckill_goods_vo: PromotionSeckillgoodsvo? = null


    fun getPromotionText(): String {
        var content=""
        var item=this
        if (item.minus_vo != null) {//单品立减
            val minus_vo = item.minus_vo!!
            content=String.format(ResString.get(R.string.立减_数_元),minus_vo.single_reduction_value)
        }else if (item.full_discount_vo != null) {//满减组合
            val full_discount_vo = item.full_discount_vo!!
            content= String.format(ResString.get(R.string.满_数_减_数_元),
                    full_discount_vo!!.full_money,
                    full_discount_vo!!.point_value)
        }else if (item.half_price_vo != null) {//第二件半价
            content= ResString.get(R.string.该商品第二件半价)
        }else if (item.exchange != null) {//积分商城
            val exchange = item.exchange!!
            content=String.format(ResString.get(R.string.赠送_数_积分),exchange.exchange_point)
        }else if (item.groupbuy_goods_vo != null) {//团购
            content=ResString.get(R.string.团购)
        }else if (item.seckill_goods_vo != null) {//秒杀
            val seckill_goods_vo = item.seckill_goods_vo!!
            content= String.format(ResString.get(R.string.天_小时_分钟_分钟后开始), TimeHandle.getDay(seckill_goods_vo.distance_start_time.toInt()),
                    TimeHandle.getHour(seckill_goods_vo.distance_start_time.toInt()),
                    TimeHandle.getSecond(seckill_goods_vo.distance_start_time.toInt()))
        }
        return content
    }

    override val itemType: Int
        get() = 2
}

/**单品立减*/
class PromotionMinusvo : Serializable {
    //立减
    var single_reduction_value = 0.0
}

/**满减组合*/
class PromotionFulldiscountvoModel : Serializable {
    var fd_id = 0
    //满多少
    var full_money = 0.0
    //减多少
    var point_value = 0.0
}

/**第二件半价*/
class PromotionHalfpricevo : Serializable {

}

/**积分商城*/
class PromotionExchange : Serializable {
    var exchange_id = 0
    //满多少
    var exchange_money = 0.0
    //送多少积分
    var exchange_point = 0
}

/**团购*/
class PromotionGroupbuygoodsvo : Serializable {
    var act_id = 0
    //团购价
    var price = 0.0
    //原始价
    var original_price = 0.0
}

/**秒杀*/
class PromotionSeckillgoodsvo : Serializable {
    var activity_id = 0
    //秒杀价
    var seckill_price = 0.0
    //原始价
    var original_price = 0.0
    var seckill_start_time = 0L
    var distance_start_time = 0L
    var distance_end_time = 0L


}
/*
{
    "goods_id": 8490,
    "thumbnail": null,
    "name": null,
    "sku_id": null,
    "start_time": 1578883734,
    "end_time": 1582944534,
    "activity_id": 8,
    "promotion_type": "FULL_DISCOUNT",
    "title": "测试满减",
    "exchange": null,
    "groupbuy_goods_vo": null,
    "full_discount_vo": {
        "fd_id": 8,
        "full_money": 101,
        "is_full_minus": 1,
        "minus_value": 100,
        "is_discount": 0,
        "discount_value": null,
        "is_send_point": 1,
        "point_value": 50,
        "is_free_ship": 1,
        "is_send_gift": 0,
        "gift_id": null,
        "is_send_bonus": 1,
        "bonus_id": 31,
        "start_time": 1578883734,
        "end_time": 1582944534,
        "title": "测试满减",
        "range_type": 2,
        "disabled": null,
        "description": "<p>这是测试满减满赠是否能用<\/p>",
        "seller_id": 64,
        "goods_list": [
            {
                "goods_id": 8464,
                "goods_name": "库存第十八次测试",
                "thumbnail": "http:\/\/47.88.173.86:82\/testShopImg
                "sn": "xm564654787",
                "price": 20,
                "quantity": 810,
                "seller_id": null,
                "enable_quantity": 9999
            },
            {
                "goods_id": 8465,
                "goods_name": "库存第十九次测试",
                "thumbnail": "http:\/\/47.88.173.86:82\/testShopImg
                "sn": "xm66669999",
                "price": 20,
                "quantity": -2330,
                "seller_id": null,
                "enable_quantity": 9999
            },
            {
                "goods_id": 8466,
                "goods_name": "库存第二十次测试",
                "thumbnail": "http:\/\/47.88.173.86:82\/testShopImg
                "sn": "xm66668888",
                "price": 20,
                "quantity": -850,
                "seller_id": null,
                "enable_quantity": 9999
            },
            {
                "goods_id": 8475,
                "goods_name": "库存第二十一次测试",
                "thumbnail": "http:\/\/47.88.173.86:82\/testShopImg
                "sn": "xm77778888",
                "price": 20,
                "quantity": -560,
                "seller_id": null,
                "enable_quantity": -1235
            },
            {
                "goods_id": 8483,
                "goods_name": "库存第二十二次测试",
                "thumbnail": "http:\/\/47.88.173.86:82\/testShopImg
                "sn": "xm222222",
                "price": 20,
                "quantity": -845,
                "seller_id": null,
                "enable_quantity": -995
            },
            {
                "goods_id": 8486,
                "goods_name": "库存第二十三次测试",
                "thumbnail": "http:\/\/47.88.173.86:82\/testShopImg
                "sn": "xm333334",
                "price": 20,
                "quantity": 10,
                "seller_id": null,
                "enable_quantity": 200
            },
            {
                "goods_id": 8487,
                "goods_name": "库存第二十四次测试",
                "thumbnail": "http:\/\/47.88.173.86:82\/testShopImg
                "sn": "xm333335",
                "price": 20,
                "quantity": -480,
                "seller_id": null,
                "enable_quantity": 1295
            },
            {
                "goods_id": 8490,
                "goods_name": "库存第二十五次测试",
                "thumbnail": "http:\/\/47.88.173.86:82\/testShopImg
                "sn": "xm333336",
                "price": 20,
                "quantity": -475,
                "seller_id": null,
                "enable_quantity": -725
            },
            {
                "goods_id": 8491,
                "goods_name": "库存第二十六次测试",
                "thumbnail": "http:\/\/47.88.173.86:82\/testShopImg
                "sn": "xm333337",
                "price": 20,
                "quantity": -975,
                "seller_id": null,
                "enable_quantity": -975
            },
            {
                "goods_id": 8492,
                "goods_name": "库存第二十七次测试",
                "thumbnail": "http:\/\/47.88.173.86:82\/testShopImg
                "sn": "xm322687",
                "price": 20,
                "quantity": -100,
                "seller_id": null,
                "enable_quantity": -400
            }
        ],
        "goods_id_list": [],
        "status_text": null,
        "full_discount_gift_do": null,
        "coupon_do": {
            "coupon_id": 31,
            "title": "10",
            "coupon_price": 10,
            "coupon_price_list": null,
            "coupon_threshold_price": 50,
            "coupon_threshold_price_list": null,
            "start_time": 1578240000,
            "end_time": 1580399999,
            "create_num": 50,
            "limit_num": 1,
            "used_num": 9,
            "received_num": 29,
            "seller_id": 64,
            "seller_name": "全广州最靓的店",
            "country_id": 12
        },
        "point": 50,
        "status": null
    },
    "full_discount_gift": null,
    "minus_vo": null,
    "half_price_vo": null,
    "seckill_goods_vo": null,
    "num": null,
    "price": null
}
 */